package com.mlink.ai.chat.local

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.mlink.ai.chat.local.entity.ChatMessageEntity


@Dao
interface ChatMessageDao {

    @Query("SELECT * FROM message_history order by message_id DESC LIMIT 12")
    fun getAllMessages(): List<ChatMessageEntity>

    @Query("SELECT * FROM message_history order by message_id DESC")
    fun getAllMessagesWithoutLimit() : List<ChatMessageEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertMessage(entity: ChatMessageEntity)

    @Delete
    fun deleteMessage(entity: ChatMessageEntity)
}